# -*- coding: UTF-8 -*-
"""获取某个股票整个交易数据
# 
"""
import efinance as ef
from typing import Literal
import os
import sys

current_path = os.getcwd()
# print('当前路径：'+ current_path)
 
def stockDataToCsv(stock_code: str,category='101') -> str:
    try:
        # 获取相应股票代码数据到Pandas 数据结构 - DataFrame
        stock_quote_history_data_all=ef.stock.get_quote_history(stock_code)
        # 股票中文名
        stockName=stock_quote_history_data_all['股票名称'][1]
        # 存储路径
        pathWay=current_path+f"/code/Stock/data/{category}/{stock_code}{stockName}.csv"
        # 存储相应股票代码数据到CSV
        stock_quote_history_data_all.to_csv(pathWay, index=False)
    except Exception:
        return 'error'
    else:
        return 'ok'


result=stockDataToCsv('000001')
print(result)

    



